package com.fenghuajueli.module_home;

import android.view.View;

import androidx.recyclerview.widget.GridLayoutManager;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.fenghuajueli.libbasecoreui.viewmodel.BaseViewModelFragment2;
import com.fenghuajueli.module_home.adapter.ToolsPageAdapter;
import com.fenghuajueli.module_home.bean.ToolsBean;
import com.fenghuajueli.module_home.databinding.FragmentToolsPageBinding;
import com.fenghuajueli.module_home.model.ToolsPageModel;
import com.fenghuajueli.module_route.CunQianJiZhangModuleRoute;
import com.fenghuajueli.module_route.HomeModuleRoute;
import com.fenghuajueli.module_route.MattersModuleRoute;
import com.fenghuajueli.module_route.MemoModuleRoute;

@Route(path = HomeModuleRoute.TOOLS_PAGE)
public class ToolsPageFragment extends BaseViewModelFragment2<ToolsPageModel, FragmentToolsPageBinding> {
    @Override
    protected ToolsPageModel createViewModel() {
        return new ToolsPageModel();
    }

    @Override
    protected FragmentToolsPageBinding createViewBinding() {
        return FragmentToolsPageBinding.inflate(getLayoutInflater());
    }

    @Override
    protected void initView(View containerView) {
        binding.recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
        ToolsPageAdapter adapter = new ToolsPageAdapter(ToolsBean.getToolsData());
        binding.recyclerView.setAdapter(adapter);
        adapter.setOnItemClickListener(new ToolsPageAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(int position) {
                if (position == 0) {
                    ARouter.getInstance().build(MemoModuleRoute.MEMO_ACTIVITY).navigation();
                } else if (position == 1) {
                    ARouter.getInstance().build(MattersModuleRoute.MATTERS_ACTIVITY).navigation();
                } else if (position == 2) {
                    ARouter.getInstance().build(CunQianJiZhangModuleRoute.JI_ZHANG_ACTIVITY).navigation();
                }
            }
        });
    }

    @Override
    protected void initData() {

    }
}
